package com.atwork.wuhua.mvp.model;

import com.atwork.wuhua.base.BaseEntity;
import com.atwork.wuhua.base.BaseModel;
import com.atwork.wuhua.base.BaseObserver;
import com.atwork.wuhua.base.MyApplication;
import com.atwork.wuhua.bean.EditInfoBean;
import com.atwork.wuhua.bean.EvaluateDetailBean;
import com.atwork.wuhua.mvp.Callback;
import com.atwork.wuhua.utils.HttpUtil.RetrofitFactory;
import com.atwork.wuhua.utils.LogUtils;

import io.reactivex.disposables.Disposable;

public class EvaluateDetailModel extends BaseModel<EvaluateDetailBean> {
    @Override
    public void execute(Callback<EvaluateDetailBean> callback) {
        getData(MyApplication.AUTH, callback);
    }

    public void getData(String auth, final Callback callback) {
        LogUtils.e("str==>" + mParams.getString());
        RetrofitFactory.getInstence().API()
                .getEvaluateDetail(auth, mParams.getSecret())
                .compose(this.<BaseEntity<EvaluateDetailBean>>setThread())
                .subscribe(new BaseObserver<EvaluateDetailBean>() {
                    @Override
                    protected void onSuccees(BaseEntity<EvaluateDetailBean> t) throws Exception {
                        if (t.isSuccess()) {
                            callback.onSuccess(t.getErrmsg(), t.getResult());
                        } else {
                            callback.onFailure(t.getErrmsg());
                        }
                    }

                    @Override
                    protected void onFailure(Throwable e, boolean isNetWorkError) throws Exception {

                    }

                    @Override
                    protected void onRequestStart(Disposable disposable) {

                    }
                });
    }
}
